﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>中国福利彩票</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<link rel="icon" href="images/favicon.png" type="image/x-icon"/>
<script src="js/jquery-1.7.2.min.js"></script>
<script src="js/angular.min.js"></script>
<script src="http://static.geetest.com/static/tools/gt.js"></script>
<style>

    .hide{
        display: none;
    }
    .show{
        display: block;
    }
</style>

</head>

<body>
	<div class="Lone">
		<div style="width:1200px;height:110px;background:#fff;margin:0 auto;padding-top:50px">
    	<div class="width1200">
        	<a href="#"><img src="images/Llogo.jpg" width="489" /></a>
        </div>
		</div>
    </div>
    <div style="width:100%;background:#bd1900;">
    <div class="Lbanner">
    	<div class="width1200" ng-controller="ctrl">
            <div class="Login">
                <div class="LO_big">
                    <form name="loginFm">
                    <div class="LO_title">
                        <a href="Register.html" class="right">免费注册</a>
                        登录
                    </div>
    
                    <div class="LO_cont">
                        <dl>
                            <dt><img src="images/LOimg1.jpg" width="40" /></dt>
                            <dd><input type="text" ng-model="user.name" id="nick" name="nick" class="LO_text" placeholder="手机号码/邮箱/用户名" /></dd>
                            <div class="clear"></div>
                        </dl>
                        <dl>
                            <dt><img src="images/LOimg2.jpg" width="40" /></dt>
                            <dd><input type="password" ng-model="user.pwd" id="pwd" name="pwd"  placeholder="登录密码"  class="LO_text" /></dd>
                            <div class="clear"></div>
                        </dl>
                    </div>
    
                    <!--                 记住密码 -->
                    <!--<div ><input name="rememberPwd" type="checkbox" value="" checked id="rememberPwd">记住密码</div>-->
                    <!--                 记住密码 -->
                        <div id="embed-captcha" class="form-group">
                            <p id="wait" class="show">正在加载验证码......</p>
                            <p id="notice" class="hide">请先拖动验证码到相应位置</p>
                            <br>
                        </div>
                    <div class="LO_paw"><a href="ForgetPassword0.html">忘记密码？</a></div>
    
                    <div class="LO_but">
                        <input type="button" value="登录" id="btnLogin" />
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    </div>
    <div class="Lfooter">
    	<div class="width1200">
        	2016  ©  中国福利彩票发行管理中心
        </div>
    </div>
    
</body>
<script type="text/javascript">
	var channelId="";
   $(document).ready(function() {
	   setCookie('channelId',"1234567890",0);
	   channelId = getCookie("channelId");
   });
 //注册成功调用login登录获得accountId和token
   function login(){
	 //验证用户名，密码
		if(!validateLogin('nick','pwd')){
			return;
		}
 	  var para = {
 			  	id:$('#nick').val(),
 				password:sha256_digest($('#pwd').val())
 	        };

 		$.ajax({
 			url : "../../api/CrmSystem/login",
 			async:false,
 			type : "POST",
 			herder:{
 				'Accept':'application/json',
 				'Content-Type':'application/json'
 			},
 			dataType:"json",
 			contentType:"application/json",
 			data: JSON.stringify(para),
 			error:function(XMLHttpRequest, textStatus, errorThrown){
 				alert(errorThrown);
 			},
 			success: function(data, textStatus){
//  				var obj = eval("("+data+")");
 				if(data.success == true){
 						setCookie('accountId',data.accountId,0);
 						setCookie('token',data.token,0);
 						setCookie('username',data.name,0);
 						setCookie('pwd',sha256_digest($('#pwd').val()),0);
 						saveUserInfo();
 						if(data.status==1000){
 							window.location.href='Register1.html?password='+sha256_digest($('#pwd').val())+'';
 						}
 						/* else if(data.status==1002){
 							window.location.href='Register2.html?type=1';
 						} */
 						else if(data.status==2000 || data.status==1002){
 							window.location.href='Xzjls.html';
 						}else{
//  							window.location.assign(encodeURI('LoginDown.html'));
							alert("登录失败！");
 							return;
 						}
 				}else{
 					alert("error:"+data.description);
 					return;
 				}
 			}
 		});
   }
   function saveUserInfo(){
		 if ($("#rememberPwd").attr("checked") == "checked") {
			 var userName = $("#nick").val();
			 var passWord = $("#pwd").val();
			 $.cookie("rmbUser", "true", { expires: 7 }); // 存储一个带7天期限的 cookie
			 $.cookie("userName", userName, { expires: 7 }); // 存储一个带7天期限的 cookie
			 $.cookie("passWord", passWord, { expires: 7 }); // 存储一个带7天期限的 cookie
		  }else{
			 $.cookie("rmbUser", "false", { expires: -1 });
			 $.cookie("userName", '', { expires: -1 });
			 $.cookie("passWord", '', { expires: -1 });
		  }
	 }



    var handlerEmbed = function (captchaObj) {
        $("#btnLogin").click(function (e) {
            var validate = captchaObj.getValidate();
            if (!validate) {
                $("#notice")[0].className = "show";
                setTimeout(function () {
                    $("#notice")[0].className = "hide";
                }, 2000);
                e.preventDefault();
                return;
            }
            login();
        });
        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
        captchaObj.appendTo("#embed-captcha");
        captchaObj.onReady(function () {
            $("#wait")[0].className = "hide";
        });
        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
    };



    $.ajax({
        // 获取id，challenge，success（是否启用failback）
        url: "../../api/CrmSystem/gee/loginInit?t=" + (new Date()).getTime(), // 加随机数防止缓存
        type: "get",
        dataType: "json",
        success: function (data) {
            // 使用initGeetest接口
            // 参数1：配置参数
            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
            initGeetest({
                gt: data.gt,
                challenge: data.challenge,
                product: "float", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
                // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
            }, handlerEmbed);
        }
    });

</script>
<script src="js/jsCallCookies.js"></script>
<script src="js/SHA256.js"></script>
<script src="js/validation.js"></script>
<script src="js/jquery.cookie.js"></script>
</html>
